package com.example.hehecat.yuejian1.mvp.presenter;

import com.example.hehecat.yuejian1.mvp.contract.ListContract;
import com.example.hehecat.yuejian1.mvp.model.ClubListModel;
import com.example.hehecat.yuejian1.mvp.model.bean.ClubBean;

import java.util.List;

import rx.Subscriber;

public class ClubListPresenter implements ListContract.Presenter {
    private ListContract.View<ClubBean> view;
    private ListContract.Model<ClubBean> model;

    public ClubListPresenter(ListContract.View<ClubBean> view) {
        this.view = view;
        model = new ClubListModel();
    }


    @Override
    public void updateAdapterData() {
        model.getAllData(new Subscriber<List<ClubBean>>() {
            @Override
            public void onCompleted() {

            }

            @Override
            public void onError(Throwable e) {

            }

            @Override
            public void onNext(List<ClubBean> clubBeans) {
                view.updateAdapterData(clubBeans);
            }
        });
    }

    @Override
    public void updateSearchData(String seaerch) {
        model = new ClubListModel();
        model.getSearchData(seaerch, new Subscriber<List<ClubBean>>() {
            @Override
            public void onCompleted() {

            }

            @Override
            public void onError(Throwable e) {

            }

            @Override
            public void onNext(List<ClubBean> clubBeans) {
                view.updateAdapterData(clubBeans);
            }
        });
    }


}
